<h1 id="快速开始"><a href="#快速开始" class="headerlink" title="快速开始"></a>快速开始</h1><h2 id="HTML-片段"><a href="#HTML-片段" class="headerlink" title="HTML 片段"></a>HTML 片段</h2><p>请在需要评论框的<code>文章页</code>内相应位置引入下面的HTML代码：</p>
<pre><code class="html"><span class="tag">&lt;<span class="name">head</span>&gt;</span>
    ...
    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">"//cdn1.lncld.net/static/js/3.0.4/av-min.js"</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span>
    <span class="tag">&lt;<span class="name">script</span> <span class="attr">src</span>=<span class="string">'//unpkg.com/valine/dist/Valine.min.js'</span>&gt;</span><span class="undefined"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span>
    ...
<span class="tag">&lt;/<span class="name">head</span>&gt;</span>
<span class="tag">&lt;<span class="name">body</span>&gt;</span>
    ...
    <span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"comment"</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span>
<span class="tag">&lt;/<span class="name">body</span>&gt;</span>
</code></pre>
<h2 id="获取appid和appkey"><a href="#获取appid和appkey" class="headerlink" title="获取appid和appkey"></a>获取appid和appkey</h2><p>请先<a href="https://leancloud.cn/dashboard/login.html#/signin">登录</a>或<a href="https://leancloud.cn/dashboard/login.html#/signup">注册</a> <code>LeanCloud</code>, 进入<a href="https://leancloud.cn/dashboard/applist.html#/apps">控制台</a>后点击左下角<a href="https://leancloud.cn/dashboard/applist.html#/newapp">创建应用</a>：</p>
<p><img src="https://ws1.sinaimg.cn/large/006qRazegy1fkwo2fpoetj30h40coaak.jpg" alt=""></p>
<p>应用创建好以后，进入刚刚创建的应用，选择左下角的<code>设置</code>&gt;<code>应用Key</code>，然后就能看到你的<code>appid</code>和<code>appkey</code>了：</p>
<p><img src="https://ws1.sinaimg.cn/large/006qRazegy1fkwo6w2b6uj30xe0etjt4.jpg" alt=""></p>
<p>!&gt; 为了您的数据安全，请注意设置自己的<code>安全域名</code>：</p>
<p><img src="https://ws1.sinaimg.cn/large/006qRazegy1fkxqmddfh1j30qd0go40h.jpg" alt="设置安全域名"></p>
<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><p>修改初始化对象中的<code>appId</code>和<code>appKey</code>的值为上面刚刚获取到的值即可(其他可以默认)。</p>
<pre><code class="js"><span class="keyword">new</span> Valine({
    el: <span class="string">'#comment'</span> ,
    notify:<span class="literal">false</span>, 
    verify:<span class="literal">false</span>, 
    appId: <span class="string">'这里填上面获得的appid'</span>,
    appKey: <span class="string">'这里填上面获得的appkey'</span>,
    placeholder: <span class="string">'just go go'</span>,
    path:<span class="built_in">window</span>.location.pathname, 
    avatar:<span class="string">'mm'</span> 
});
</code></pre>
<p>更多信息请查看<a href="configuration.md">配置项</a>。</p>
<h2 id="npm安装"><a href="#npm安装" class="headerlink" title="npm安装"></a>npm安装</h2><p>Valine 现已发布到<a href="https://www.npmjs.com/package/valine">npm</a>，可以直接用命令安装：</p>
<pre><code class="bash">npm install valine --save
</code></pre>
